 model{
	for(i in 1:N) { ##observation
		##form the linear predictor (No intercept and constrained Thresholds)
		mu[i] <- 	x[i,1]*beta[1] +  ##SPII component
					x[i,2]*beta[2] +  ##Capabilities
					x[i,3]*beta[3] +  ##Threat
					x[i,4]*beta[4] +  ##Major Power
					x[i,5]*beta[5] +  ##Other MIDS
					x[i,6]*beta[6] +  ##Counter (time since last)
					x[i,7]*beta[7] +  ##Force
					x[i,8]*beta[8] +  ##First move
					x[i,9]*beta[9] +  ##Previous Mids
					x[i,10]*beta[10] +  ##Previous Losses (for High SPII State)
					alpha1[namehigh[i]] -	 ##Random Effect for Dem
					alpha2[namelow[i]]		 ##Random Effect for Non-Dem
 		##Cum. Logistic Probs.
		logit(Q[i,1]) <- tau[1] -mu[i] #tau[1] is negative
		p[i,1] <- Q[i,1]
		logit(Q[i,2]) <- tau[2] -mu[i] #tau[2] is positive
		##slice cdf
		p[i,2] <- Q[i,2]-Q[i,1]			
	
		p[i,3] <- 1-Q[i,2]
		y[i] ~ dcat(p[i,1:3])## p[i,] sums to 1 for each i
	}
	## Random Effects
	for(p1 in 1:J1) {
	alpha1[p1] ~ dnorm(mu1,prec1)
	}
	for(p2 in 1:J2) {
	alpha2[p2] ~ dnorm(mu2,prec2)
	}
	##Priors over random effects
	mu1 ~ dnorm(0,.0001)
	mu2 ~ dnorm(0,.0001)
    prec1 <- pow(sigtemp1, -2)
	prec2 <- pow(sigtemp2, -2)
	sigtemp1 ~ dunif(0,10)
	sigtemp2 ~ dunif(0,10)

	##priors over beta
	beta[1:10] ~ dmnorm(b0[],B0[,])
	
	##prior for threshold
		tau0 ~ dnorm(0,.01)	
		
	##Sort thresholds incase tau0 is negative
		tau[1] <- step(tau0)* -tau0 + step(-tau0)*tau0
		tau[2] <- step(tau0)* tau0 + step(-tau0)*-tau0

}


